﻿/****** Object:  ForeignKey [FK_ContentBinaryDataContent_ContentMetaDataMaster]    Script Date: 06/19/2015 23:05:26 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentBinaryDataContent_ContentMetaDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentBinaryDataContent]'))
ALTER TABLE [ContentBinaryDataContent] DROP CONSTRAINT [FK_ContentBinaryDataContent_ContentMetaDataMaster]
GO
/****** Object:  ForeignKey [FK_ContentFeedback_ContentMetaDataMaster]    Script Date: 06/19/2015 23:05:26 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentFeedback_ContentMetaDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentFeedback]'))
ALTER TABLE [ContentFeedback] DROP CONSTRAINT [FK_ContentFeedback_ContentMetaDataMaster]
GO
/****** Object:  ForeignKey [FK_ContentFeedback_User]    Script Date: 06/19/2015 23:05:26 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentFeedback_User]') AND parent_object_id = OBJECT_ID(N'[ContentFeedback]'))
ALTER TABLE [ContentFeedback] DROP CONSTRAINT [FK_ContentFeedback_User]
GO
/****** Object:  ForeignKey [FK_ContentMetaDataMaster_ContentTypeMaster]    Script Date: 06/19/2015 23:05:26 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentMetaDataMaster_ContentTypeMaster]') AND parent_object_id = OBJECT_ID(N'[ContentMetaDataMaster]'))
ALTER TABLE [ContentMetaDataMaster] DROP CONSTRAINT [FK_ContentMetaDataMaster_ContentTypeMaster]
GO
/****** Object:  ForeignKey [FK_ContentRating_ContentMetaDataMaster]    Script Date: 06/19/2015 23:05:27 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentRating_ContentMetaDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentRating]'))
ALTER TABLE [ContentRating] DROP CONSTRAINT [FK_ContentRating_ContentMetaDataMaster]
GO
/****** Object:  ForeignKey [FK_ContentRating_User]    Script Date: 06/19/2015 23:05:27 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentRating_User]') AND parent_object_id = OBJECT_ID(N'[ContentRating]'))
ALTER TABLE [ContentRating] DROP CONSTRAINT [FK_ContentRating_User]
GO
/****** Object:  ForeignKey [FK__Feedback__Feedba__370627FE]    Script Date: 06/19/2015 23:05:27 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK__Feedback__Feedba__370627FE]') AND parent_object_id = OBJECT_ID(N'[Feedback]'))
ALTER TABLE [Feedback] DROP CONSTRAINT [FK__Feedback__Feedba__370627FE]
GO
/****** Object:  ForeignKey [FK_FeedbackUser_User]    Script Date: 06/19/2015 23:05:27 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_FeedbackUser_User]') AND parent_object_id = OBJECT_ID(N'[FeedbackUser]'))
ALTER TABLE [FeedbackUser] DROP CONSTRAINT [FK_FeedbackUser_User]
GO
/****** Object:  ForeignKey [FK_Sys_ActivityMaster_Sys_ActivityTypeMaster]    Script Date: 06/19/2015 23:05:27 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_ActivityMaster_Sys_ActivityTypeMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_ActivityMaster]'))
ALTER TABLE [Sys_ActivityMaster] DROP CONSTRAINT [FK_Sys_ActivityMaster_Sys_ActivityTypeMaster]
GO
/****** Object:  ForeignKey [FK_Sys_RoleActivity_Sys_ActivityMaster]    Script Date: 06/19/2015 23:05:27 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_RoleActivity_Sys_ActivityMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_RoleActivity]'))
ALTER TABLE [Sys_RoleActivity] DROP CONSTRAINT [FK_Sys_RoleActivity_Sys_ActivityMaster]
GO
/****** Object:  ForeignKey [FK_Sys_RoleActivity_Sys_RoleMaster]    Script Date: 06/19/2015 23:05:27 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_RoleActivity_Sys_RoleMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_RoleActivity]'))
ALTER TABLE [Sys_RoleActivity] DROP CONSTRAINT [FK_Sys_RoleActivity_Sys_RoleMaster]
GO
/****** Object:  ForeignKey [FK_Sys_TableMaster_Sys_ModuleMaster]    Script Date: 06/19/2015 23:05:27 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_TableMaster_Sys_ModuleMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_TableMaster]'))
ALTER TABLE [Sys_TableMaster] DROP CONSTRAINT [FK_Sys_TableMaster_Sys_ModuleMaster]
GO
/****** Object:  ForeignKey [FK_UserProfile_User]    Script Date: 06/19/2015 23:05:28 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserProfile_User]') AND parent_object_id = OBJECT_ID(N'[UserProfile]'))
ALTER TABLE [UserProfile] DROP CONSTRAINT [FK_UserProfile_User]
GO
/****** Object:  ForeignKey [FK_UserProfileImage_User]    Script Date: 06/19/2015 23:05:28 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserProfileImage_User]') AND parent_object_id = OBJECT_ID(N'[UserProfileImage]'))
ALTER TABLE [UserProfileImage] DROP CONSTRAINT [FK_UserProfileImage_User]
GO
/****** Object:  ForeignKey [FK_UserRole_Sys_RoleMaster]    Script Date: 06/19/2015 23:05:28 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserRole_Sys_RoleMaster]') AND parent_object_id = OBJECT_ID(N'[UserRole]'))
ALTER TABLE [UserRole] DROP CONSTRAINT [FK_UserRole_Sys_RoleMaster]
GO
/****** Object:  ForeignKey [FK_UserRole_User]    Script Date: 06/19/2015 23:05:28 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserRole_User]') AND parent_object_id = OBJECT_ID(N'[UserRole]'))
ALTER TABLE [UserRole] DROP CONSTRAINT [FK_UserRole_User]
GO
/****** Object:  Table [ContentBinaryDataContent]    Script Date: 06/19/2015 23:05:26 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentBinaryDataContent_ContentMetaDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentBinaryDataContent]'))
ALTER TABLE [ContentBinaryDataContent] DROP CONSTRAINT [FK_ContentBinaryDataContent_ContentMetaDataMaster]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContentBinaryDataContent]') AND type in (N'U'))
DROP TABLE [ContentBinaryDataContent]
GO
/****** Object:  Table [ContentFeedback]    Script Date: 06/19/2015 23:05:26 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentFeedback_ContentMetaDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentFeedback]'))
ALTER TABLE [ContentFeedback] DROP CONSTRAINT [FK_ContentFeedback_ContentMetaDataMaster]
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentFeedback_User]') AND parent_object_id = OBJECT_ID(N'[ContentFeedback]'))
ALTER TABLE [ContentFeedback] DROP CONSTRAINT [FK_ContentFeedback_User]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContentFeedback]') AND type in (N'U'))
DROP TABLE [ContentFeedback]
GO
/****** Object:  Table [Feedback]    Script Date: 06/19/2015 23:05:27 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK__Feedback__Feedba__370627FE]') AND parent_object_id = OBJECT_ID(N'[Feedback]'))
ALTER TABLE [Feedback] DROP CONSTRAINT [FK__Feedback__Feedba__370627FE]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Feedback]') AND type in (N'U'))
DROP TABLE [Feedback]
GO
/****** Object:  Table [Sys_RoleActivity]    Script Date: 06/19/2015 23:05:27 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_RoleActivity_Sys_ActivityMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_RoleActivity]'))
ALTER TABLE [Sys_RoleActivity] DROP CONSTRAINT [FK_Sys_RoleActivity_Sys_ActivityMaster]
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_RoleActivity_Sys_RoleMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_RoleActivity]'))
ALTER TABLE [Sys_RoleActivity] DROP CONSTRAINT [FK_Sys_RoleActivity_Sys_RoleMaster]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_RoleActivity]') AND type in (N'U'))
DROP TABLE [Sys_RoleActivity]
GO
/****** Object:  Table [ContentRating]    Script Date: 06/19/2015 23:05:27 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentRating_ContentMetaDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentRating]'))
ALTER TABLE [ContentRating] DROP CONSTRAINT [FK_ContentRating_ContentMetaDataMaster]
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentRating_User]') AND parent_object_id = OBJECT_ID(N'[ContentRating]'))
ALTER TABLE [ContentRating] DROP CONSTRAINT [FK_ContentRating_User]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContentRating]') AND type in (N'U'))
DROP TABLE [ContentRating]
GO
/****** Object:  Table [UserProfile]    Script Date: 06/19/2015 23:05:28 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserProfile_User]') AND parent_object_id = OBJECT_ID(N'[UserProfile]'))
ALTER TABLE [UserProfile] DROP CONSTRAINT [FK_UserProfile_User]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[UserProfile]') AND type in (N'U'))
DROP TABLE [UserProfile]
GO
/****** Object:  Table [UserProfileImage]    Script Date: 06/19/2015 23:05:28 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserProfileImage_User]') AND parent_object_id = OBJECT_ID(N'[UserProfileImage]'))
ALTER TABLE [UserProfileImage] DROP CONSTRAINT [FK_UserProfileImage_User]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[UserProfileImage]') AND type in (N'U'))
DROP TABLE [UserProfileImage]
GO
/****** Object:  Table [UserRole]    Script Date: 06/19/2015 23:05:28 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserRole_Sys_RoleMaster]') AND parent_object_id = OBJECT_ID(N'[UserRole]'))
ALTER TABLE [UserRole] DROP CONSTRAINT [FK_UserRole_Sys_RoleMaster]
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserRole_User]') AND parent_object_id = OBJECT_ID(N'[UserRole]'))
ALTER TABLE [UserRole] DROP CONSTRAINT [FK_UserRole_User]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[UserRole]') AND type in (N'U'))
DROP TABLE [UserRole]
GO
/****** Object:  Table [Sys_TableMaster]    Script Date: 06/19/2015 23:05:27 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_TableMaster_Sys_ModuleMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_TableMaster]'))
ALTER TABLE [Sys_TableMaster] DROP CONSTRAINT [FK_Sys_TableMaster_Sys_ModuleMaster]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_TableMaster]') AND type in (N'U'))
DROP TABLE [Sys_TableMaster]
GO
/****** Object:  Table [FeedbackUser]    Script Date: 06/19/2015 23:05:27 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_FeedbackUser_User]') AND parent_object_id = OBJECT_ID(N'[FeedbackUser]'))
ALTER TABLE [FeedbackUser] DROP CONSTRAINT [FK_FeedbackUser_User]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[FeedbackUser]') AND type in (N'U'))
DROP TABLE [FeedbackUser]
GO
/****** Object:  Table [ContentMetaDataMaster]    Script Date: 06/19/2015 23:05:26 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentMetaDataMaster_ContentTypeMaster]') AND parent_object_id = OBJECT_ID(N'[ContentMetaDataMaster]'))
ALTER TABLE [ContentMetaDataMaster] DROP CONSTRAINT [FK_ContentMetaDataMaster_ContentTypeMaster]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContentMetaDataMaster]') AND type in (N'U'))
DROP TABLE [ContentMetaDataMaster]
GO
/****** Object:  Table [Sys_ActivityMaster]    Script Date: 06/19/2015 23:05:27 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_ActivityMaster_Sys_ActivityTypeMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_ActivityMaster]'))
ALTER TABLE [Sys_ActivityMaster] DROP CONSTRAINT [FK_Sys_ActivityMaster_Sys_ActivityTypeMaster]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_ActivityMaster]') AND type in (N'U'))
DROP TABLE [Sys_ActivityMaster]
GO
/****** Object:  Table [Sys_ActivityTypeMaster]    Script Date: 06/19/2015 23:05:27 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_ActivityTypeMaster]') AND type in (N'U'))
DROP TABLE [Sys_ActivityTypeMaster]
GO
/****** Object:  Table [Sys_ErrorLog]    Script Date: 06/19/2015 23:05:27 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_ErrorLog]') AND type in (N'U'))
DROP TABLE [Sys_ErrorLog]
GO
/****** Object:  Table [Sys_LoginHistoryLog]    Script Date: 06/19/2015 23:05:27 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_LoginHistoryLog]') AND type in (N'U'))
DROP TABLE [Sys_LoginHistoryLog]
GO
/****** Object:  Table [Sys_ModuleMaster]    Script Date: 06/19/2015 23:05:27 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_ModuleMaster]') AND type in (N'U'))
DROP TABLE [Sys_ModuleMaster]
GO
/****** Object:  Table [Sys_OrganizationMaster]    Script Date: 06/19/2015 23:05:27 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_OrganizationMaster]') AND type in (N'U'))
DROP TABLE [Sys_OrganizationMaster]
GO
/****** Object:  Table [ProjectMemberMaster]    Script Date: 06/19/2015 23:05:27 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ProjectMemberMaster]') AND type in (N'U'))
DROP TABLE [ProjectMemberMaster]
GO
/****** Object:  Table [ResourceStat]    Script Date: 06/19/2015 23:05:27 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ResourceStat]') AND type in (N'U'))
DROP TABLE [ResourceStat]
GO
/****** Object:  Table [SubscriptionMaster]    Script Date: 06/19/2015 23:05:27 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[SubscriptionMaster]') AND type in (N'U'))
DROP TABLE [SubscriptionMaster]
GO
/****** Object:  Table [User]    Script Date: 06/19/2015 23:05:28 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[User]') AND type in (N'U'))
DROP TABLE [User]
GO
/****** Object:  Table [ContentTypeMaster]    Script Date: 06/19/2015 23:05:27 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContentTypeMaster]') AND type in (N'U'))
DROP TABLE [ContentTypeMaster]
GO
/****** Object:  Table [Sys_RoleMaster]    Script Date: 06/19/2015 23:05:27 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_RoleMaster]') AND type in (N'U'))
DROP TABLE [Sys_RoleMaster]
GO
/****** Object:  Table [Sys_SessionLog]    Script Date: 06/19/2015 23:05:27 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_SessionLog]') AND type in (N'U'))
DROP TABLE [Sys_SessionLog]
GO
/****** Object:  Table [ContactRequestRegister]    Script Date: 06/19/2015 23:05:26 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContactRequestRegister]') AND type in (N'U'))
DROP TABLE [ContactRequestRegister]
GO
/****** Object:  Table [ContactRequestRegister]    Script Date: 06/19/2015 23:05:26 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContactRequestRegister]') AND type in (N'U'))
BEGIN
CREATE TABLE [ContactRequestRegister](
	[ContactRequestKey] [int] IDENTITY(1,1) NOT NULL,
	[ContactRequesterName] [varchar](150) NOT NULL,
	[ContactRequesterEmail] [varchar](150) NOT NULL,
	[ContactRequestMessage] [varchar](max) NOT NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_ContactRequestRegister] PRIMARY KEY CLUSTERED 
(
	[ContactRequestKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContactRequestRegister', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContactRequestRegister', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContactRequestRegister', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContactRequestRegister', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContactRequestRegister', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContactRequestRegister', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContactRequestRegister', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContactRequestRegister', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContactRequestRegister', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContactRequestRegister', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [Sys_SessionLog]    Script Date: 06/19/2015 23:05:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_SessionLog]') AND type in (N'U'))
BEGIN
CREATE TABLE [Sys_SessionLog](
	[SessionLogPrimaryID] [int] IDENTITY(1,1) NOT NULL,
	[UserSessionID] [varchar](500) NOT NULL,
	[UserIPAddress] [varchar](50) NULL,
	[UserSessionStartTime] [datetime] NOT NULL,
	[UserSessionEndTime] [datetime] NULL,
	[UserBrowserName] [nvarchar](150) NULL,
	[UserKey] [int] NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_Sys_SessionLog] PRIMARY KEY CLUSTERED 
(
	[SessionLogPrimaryID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_SessionLog', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_SessionLog', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_SessionLog', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_SessionLog', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_SessionLog', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_SessionLog', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_SessionLog', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_SessionLog', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_SessionLog', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_SessionLog', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [Sys_RoleMaster]    Script Date: 06/19/2015 23:05:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_RoleMaster]') AND type in (N'U'))
BEGIN
CREATE TABLE [Sys_RoleMaster](
	[RoleKey] [int] IDENTITY(1,1) NOT NULL,
	[RoleCode] [varchar](20) NOT NULL,
	[RoleName] [varchar](50) NOT NULL,
	[RoleDescription] [varchar](1000) NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_Sys_RoleMaster] PRIMARY KEY CLUSTERED 
(
	[RoleKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [Unique_RoleCode] UNIQUE NONCLUSTERED 
(
	[RoleCode] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [Unique_RoleName] UNIQUE NONCLUSTERED 
(
	[RoleName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_RoleMaster', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_RoleMaster', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_RoleMaster', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_RoleMaster', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_RoleMaster', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_RoleMaster', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_RoleMaster', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_RoleMaster', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_RoleMaster', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_RoleMaster', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [ContentTypeMaster]    Script Date: 06/19/2015 23:05:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContentTypeMaster]') AND type in (N'U'))
BEGIN
CREATE TABLE [ContentTypeMaster](
	[ContentTypeKey] [int] IDENTITY(1,1) NOT NULL,
	[ContentTypeCode] [varchar](20) NOT NULL,
	[ContentTypeName] [varchar](50) NOT NULL,
	[ContentDescription] [varchar](500) NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_ContentTypeMaster] PRIMARY KEY CLUSTERED 
(
	[ContentTypeKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[ContentTypeMaster]') AND name = N'Unique_ContentTypeCode')
CREATE UNIQUE NONCLUSTERED INDEX [Unique_ContentTypeCode] ON [ContentTypeMaster] 
(
	[ContentTypeCode] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentTypeMaster', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentTypeMaster', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentTypeMaster', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentTypeMaster', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentTypeMaster', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentTypeMaster', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentTypeMaster', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentTypeMaster', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentTypeMaster', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentTypeMaster', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [User]    Script Date: 06/19/2015 23:05:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[User]') AND type in (N'U'))
BEGIN
CREATE TABLE [User](
	[UserKey] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
	[UserLoginID] [varchar](50) NOT NULL,
	[UserPassword] [varchar](100) NULL,
	[UserFirstName] [varchar](50) NULL,
	[UserLastName] [varchar](50) NULL,
	[UserPrimaryEmailID] [varchar](150) NULL,
	[UserVerificationCode] [varchar](50) NULL,
	[UserIsVerified] [bit] NOT NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED 
(
	[UserKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [Unique_UserLoginID] UNIQUE NONCLUSTERED 
(
	[UserLoginID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [Unique_UserPrimaryEmailID] UNIQUE NONCLUSTERED 
(
	[UserPrimaryEmailID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'User', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'User', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'User', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'User', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'User', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [SubscriptionMaster]    Script Date: 06/19/2015 23:05:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[SubscriptionMaster]') AND type in (N'U'))
BEGIN
CREATE TABLE [SubscriptionMaster](
	[SubscribKey] [int] IDENTITY(1,1) NOT NULL,
	[SubscribItemCode] [int] NULL,
	[SubscribItemDescription] [varchar](1000) NULL,
	[SubscribUserMailID] [varchar](150) NULL,
	[SubscrbDate] [datetime] NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_SubscriptionMaster] PRIMARY KEY CLUSTERED 
(
	[SubscribKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[SubscriptionMaster]') AND name = N'UniqueSubscrib')
CREATE UNIQUE NONCLUSTERED INDEX [UniqueSubscrib] ON [SubscriptionMaster] 
(
	[SubscribItemCode] ASC,
	[SubscribUserMailID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [ResourceStat]    Script Date: 06/19/2015 23:05:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ResourceStat]') AND type in (N'U'))
BEGIN
CREATE TABLE [ResourceStat](
	[ResourceKey] [int] NOT NULL,
	[ResourceDescription] [varchar](1000) NULL,
	[ResourceContentTypeKey] [int] NULL,
	[ResourceTotalDownloads] [int] NOT NULL,
	[ResourceTotalLikes] [int] NULL,
	[ResourceTotalViews] [int] NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_ResourceStat] PRIMARY KEY CLUSTERED 
(
	[ResourceKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ResourceStat', N'COLUMN',N'ResourceContentTypeKey'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ResourceStat', @level2type=N'COLUMN',@level2name=N'ResourceContentTypeKey'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ResourceStat', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ResourceStat', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ResourceStat', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ResourceStat', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ResourceStat', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ResourceStat', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ResourceStat', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ResourceStat', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ResourceStat', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ResourceStat', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [ProjectMemberMaster]    Script Date: 06/19/2015 23:05:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ProjectMemberMaster]') AND type in (N'U'))
BEGIN
CREATE TABLE [ProjectMemberMaster](
	[ProjectMemberKey] [int] IDENTITY(1,1) NOT NULL,
	[ProjectMemberUserKey] [int] NULL,
	[ProjectMemberFirstName] [varchar](50) NOT NULL,
	[ProjectMemberLastName] [varchar](50) NULL,
	[ProjectMemberPrimaryEmailID] [varchar](150) NOT NULL,
	[ProjectMemberCodePlexID] [varchar](50) NOT NULL,
	[ProjectMemberSkypeID] [varchar](50) NOT NULL,
	[ProjectMemberMicrosoftID] [varchar](50) NULL,
	[ProjectMemberGoogleID] [varchar](50) NULL,
	[ProjectMemberTimeZoneReference] [varchar](50) NULL,
	[ProjectMemberTimeZoneName] [varchar](250) NULL,
	[ProjectMemberTimeZoneAbbreviation] [varchar](50) NULL,
	[ProjectMemberCountryName] [varchar](150) NULL,
	[ProjectMemberCityName] [varchar](150) NULL,
	[ProjectMemberDateOfJoining] [datetime] NULL,
	[ProjectMemberIsMemberOfFacebook] [bit] NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_ProjectMemberMaster] PRIMARY KEY CLUSTERED 
(
	[ProjectMemberKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[ProjectMemberMaster]') AND name = N'ProjectMember_UniqueEmailID')
CREATE UNIQUE NONCLUSTERED INDEX [ProjectMember_UniqueEmailID] ON [ProjectMemberMaster] 
(
	[ProjectMemberPrimaryEmailID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ProjectMemberMaster', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ProjectMemberMaster', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ProjectMemberMaster', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ProjectMemberMaster', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ProjectMemberMaster', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ProjectMemberMaster', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ProjectMemberMaster', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ProjectMemberMaster', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ProjectMemberMaster', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ProjectMemberMaster', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [Sys_OrganizationMaster]    Script Date: 06/19/2015 23:05:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_OrganizationMaster]') AND type in (N'U'))
BEGIN
CREATE TABLE [Sys_OrganizationMaster](
	[OrganizationID] [int] NOT NULL,
	[OrganizationName] [varchar](50) NOT NULL,
	[OrganizationDescription] [nvarchar](max) NULL,
	[OrganizationDomainURL] [varchar](max) NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_Sys_OrganizationMaster] PRIMARY KEY CLUSTERED 
(
	[OrganizationID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_OrganizationMaster', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_OrganizationMaster', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_OrganizationMaster', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_OrganizationMaster', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_OrganizationMaster', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_OrganizationMaster', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_OrganizationMaster', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_OrganizationMaster', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_OrganizationMaster', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_OrganizationMaster', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [Sys_ModuleMaster]    Script Date: 06/19/2015 23:05:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_ModuleMaster]') AND type in (N'U'))
BEGIN
CREATE TABLE [Sys_ModuleMaster](
	[ModuleID] [int] NOT NULL,
	[ModuleName] [varchar](50) NOT NULL,
	[ModuleDescription] [nvarchar](max) NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_Sys_ModuleMaster] PRIMARY KEY CLUSTERED 
(
	[ModuleID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_ModuleMaster', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ModuleMaster', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_ModuleMaster', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ModuleMaster', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_ModuleMaster', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ModuleMaster', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_ModuleMaster', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ModuleMaster', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_ModuleMaster', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ModuleMaster', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [Sys_LoginHistoryLog]    Script Date: 06/19/2015 23:05:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_LoginHistoryLog]') AND type in (N'U'))
BEGIN
CREATE TABLE [Sys_LoginHistoryLog](
	[LoginKey] [int] IDENTITY(1,1) NOT NULL,
	[LoginUserKey] [int] NOT NULL,
	[LoginUserLoginID] [varchar](50) NOT NULL,
	[LoginStartTime] [datetime] NOT NULL,
	[LoginEndTime] [datetime] NULL,
	[LoginUserBrowser] [varchar](50) NULL,
	[LoginLocation] [varchar](150) NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_LoginHistoryLog] PRIMARY KEY CLUSTERED 
(
	[LoginKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[Sys_LoginHistoryLog]') AND name = N'Unique_LoginHistory')
CREATE UNIQUE NONCLUSTERED INDEX [Unique_LoginHistory] ON [Sys_LoginHistoryLog] 
(
	[LoginUserKey] ASC,
	[LoginStartTime] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_LoginHistoryLog', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_LoginHistoryLog', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_LoginHistoryLog', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_LoginHistoryLog', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_LoginHistoryLog', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_LoginHistoryLog', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_LoginHistoryLog', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_LoginHistoryLog', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_LoginHistoryLog', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_LoginHistoryLog', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [Sys_ErrorLog]    Script Date: 06/19/2015 23:05:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_ErrorLog]') AND type in (N'U'))
BEGIN
CREATE TABLE [Sys_ErrorLog](
	[ErrorLogPrimaryID] [int] IDENTITY(1,1) NOT NULL,
	[ApplicationName] [varchar](500) NULL,
	[MethodName] [varchar](500) NULL,
	[ErrorMessage] [varchar](max) NOT NULL,
	[StackTrace] [varchar](max) NOT NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_Sys_ErrorLog_1] PRIMARY KEY CLUSTERED 
(
	[ErrorLogPrimaryID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_ErrorLog', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ErrorLog', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_ErrorLog', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ErrorLog', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_ErrorLog', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ErrorLog', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_ErrorLog', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ErrorLog', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_ErrorLog', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ErrorLog', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [Sys_ActivityTypeMaster]    Script Date: 06/19/2015 23:05:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_ActivityTypeMaster]') AND type in (N'U'))
BEGIN
CREATE TABLE [Sys_ActivityTypeMaster](
	[ActivityTypeKey] [int] IDENTITY(1,1) NOT NULL,
	[ActivityTypeCode] [varchar](20) NOT NULL,
	[ActivityTypeName] [varchar](50) NOT NULL,
	[ActivityTypeDescription] [varchar](1000) NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_Sys_ActivityTypeMaster] PRIMARY KEY CLUSTERED 
(
	[ActivityTypeKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[Sys_ActivityTypeMaster]') AND name = N'Unique_ActivityTypeCode')
CREATE UNIQUE NONCLUSTERED INDEX [Unique_ActivityTypeCode] ON [Sys_ActivityTypeMaster] 
(
	[ActivityTypeCode] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[Sys_ActivityTypeMaster]') AND name = N'Unique_ActivityTypeName')
CREATE UNIQUE NONCLUSTERED INDEX [Unique_ActivityTypeName] ON [Sys_ActivityTypeMaster] 
(
	[ActivityTypeName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_ActivityTypeMaster', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ActivityTypeMaster', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_ActivityTypeMaster', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ActivityTypeMaster', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_ActivityTypeMaster', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ActivityTypeMaster', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_ActivityTypeMaster', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ActivityTypeMaster', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_ActivityTypeMaster', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ActivityTypeMaster', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [Sys_ActivityMaster]    Script Date: 06/19/2015 23:05:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_ActivityMaster]') AND type in (N'U'))
BEGIN
CREATE TABLE [Sys_ActivityMaster](
	[ActivityKey] [int] IDENTITY(1,1) NOT NULL,
	[ActivityCode] [varchar](20) NOT NULL,
	[ActivityName] [varchar](50) NOT NULL,
	[ActivityDescription] [varchar](1000) NULL,
	[ActivityTypeKey] [int] NOT NULL,
	[ActivityTypeCode] [varchar](20) NOT NULL,
	[ActivityTypeName] [varchar](50) NOT NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_Sys_ActivityMaster] PRIMARY KEY CLUSTERED 
(
	[ActivityKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[Sys_ActivityMaster]') AND name = N'Unique_ActivityMasterCode')
CREATE UNIQUE NONCLUSTERED INDEX [Unique_ActivityMasterCode] ON [Sys_ActivityMaster] 
(
	[ActivityCode] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[Sys_ActivityMaster]') AND name = N'Unique_ActivityMasterName')
CREATE UNIQUE NONCLUSTERED INDEX [Unique_ActivityMasterName] ON [Sys_ActivityMaster] 
(
	[ActivityName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_ActivityMaster', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ActivityMaster', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_ActivityMaster', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ActivityMaster', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_ActivityMaster', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ActivityMaster', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_ActivityMaster', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ActivityMaster', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_ActivityMaster', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ActivityMaster', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [ContentMetaDataMaster]    Script Date: 06/19/2015 23:05:26 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContentMetaDataMaster]') AND type in (N'U'))
BEGIN
CREATE TABLE [ContentMetaDataMaster](
	[ContentKey] [int] IDENTITY(1,1) NOT NULL,
	[ContentCode] [varchar](50) NOT NULL,
	[ContentName] [varchar](50) NOT NULL,
	[ContentMetaTagKeyword] [varchar](max) NULL,
	[ContentMetaTagDescription] [varchar](max) NULL,
	[ContentHtmlData] [nvarchar](max) NULL,
	[ContentTypeKey] [int] NULL,
	[ContentTotalDownloads] [int] NULL,
	[ContentTotalLikes] [int] NULL,
	[ContentTotalViews] [int] NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_ContentMetaDataMaster] PRIMARY KEY CLUSTERED 
(
	[ContentKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [Unique_ContentMetaDataMaster_ContentCode] UNIQUE NONCLUSTERED 
(
	[ContentKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[ContentMetaDataMaster]') AND name = N'Unique_ContentMetaDataMaster')
CREATE UNIQUE NONCLUSTERED INDEX [Unique_ContentMetaDataMaster] ON [ContentMetaDataMaster] 
(
	[ContentName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentMetaDataMaster', N'COLUMN',N'ContentMetaTagKeyword'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Seach Keywords seperated by comma (,)' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentMetaDataMaster', @level2type=N'COLUMN',@level2name=N'ContentMetaTagKeyword'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentMetaDataMaster', N'COLUMN',N'ContentTypeKey'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentMetaDataMaster', @level2type=N'COLUMN',@level2name=N'ContentTypeKey'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentMetaDataMaster', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentMetaDataMaster', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentMetaDataMaster', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentMetaDataMaster', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentMetaDataMaster', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentMetaDataMaster', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentMetaDataMaster', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentMetaDataMaster', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentMetaDataMaster', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentMetaDataMaster', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [FeedbackUser]    Script Date: 06/19/2015 23:05:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[FeedbackUser]') AND type in (N'U'))
BEGIN
CREATE TABLE [FeedbackUser](
	[FeedbackUserKey] [int] IDENTITY(1,1) NOT NULL,
	[FeedbackUserName] [varchar](150) NOT NULL,
	[FeedbackUserEmail] [varchar](150) NOT NULL,
	[RegisteredUserKey] [int] NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_FeedbackUser] PRIMARY KEY CLUSTERED 
(
	[FeedbackUserKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [Unique_FeedbackUserEmail] UNIQUE NONCLUSTERED 
(
	[FeedbackUserEmail] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [FeedbackUser] SET (LOCK_ESCALATION = AUTO)
GO
/****** Object:  Table [Sys_TableMaster]    Script Date: 06/19/2015 23:05:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_TableMaster]') AND type in (N'U'))
BEGIN
CREATE TABLE [Sys_TableMaster](
	[TableID] [int] NOT NULL,
	[TableName] [varchar](50) NOT NULL,
	[TableDescription] [varchar](max) NULL,
	[TableSequenceNo] [int] NULL,
	[ModuleID] [int] NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_Sys_TableMaster] PRIMARY KEY CLUSTERED 
(
	[TableID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_TableMaster', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_TableMaster', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_TableMaster', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_TableMaster', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_TableMaster', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_TableMaster', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_TableMaster', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_TableMaster', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_TableMaster', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_TableMaster', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [UserRole]    Script Date: 06/19/2015 23:05:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[UserRole]') AND type in (N'U'))
BEGIN
CREATE TABLE [UserRole](
	[UserKey] [int] NOT NULL,
	[UserRoleKey] [int] NOT NULL,
	[UserLoginID] [varchar](50) NOT NULL,
	[UserRoleCode] [varchar](20) NOT NULL,
	[UserRoleName] [varchar](50) NOT NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_UserRole_1] PRIMARY KEY CLUSTERED 
(
	[UserKey] ASC,
	[UserRoleKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'UserRole', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'UserRole', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'UserRole', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'UserRole', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'UserRole', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'UserRole', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'UserRole', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'UserRole', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'UserRole', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'UserRole', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [UserProfileImage]    Script Date: 06/19/2015 23:05:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[UserProfileImage]') AND type in (N'U'))
BEGIN
CREATE TABLE [UserProfileImage](
	[UserKey] [int] NOT NULL,
	[UserLoginID] [varchar](50) NOT NULL,
	[UserProfileImageData] [varbinary](max) NULL,
	[UserImageType] [varchar](1000) NULL,
	[UserImageFileName] [varchar](1000) NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_UserProfileImage] PRIMARY KEY CLUSTERED 
(
	[UserKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'UserProfileImage', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'UserProfileImage', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'UserProfileImage', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'UserProfileImage', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'UserProfileImage', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'UserProfileImage', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'UserProfileImage', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'UserProfileImage', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'UserProfileImage', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'UserProfileImage', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [UserProfile]    Script Date: 06/19/2015 23:05:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[UserProfile]') AND type in (N'U'))
BEGIN
CREATE TABLE [UserProfile](
	[UserKey] [int] NOT NULL,
	[UserFullName] [varchar](150) NULL,
	[UserSex] [char](1) NULL,
	[UserDateOfBirth] [datetime] NULL,
	[UserAlternateEmailID] [varchar](150) NULL,
	[UserContactNumber] [varchar](50) NULL,
	[UserContactAddress] [varchar](500) NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_UserProfile] PRIMARY KEY CLUSTERED 
(
	[UserKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'UserProfile', N'COLUMN',N'UserSex'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'M=Male; F=Female' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'UserProfile', @level2type=N'COLUMN',@level2name=N'UserSex'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'UserProfile', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'UserProfile', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'UserProfile', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'UserProfile', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'UserProfile', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'UserProfile', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'UserProfile', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'UserProfile', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'UserProfile', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'UserProfile', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [ContentRating]    Script Date: 06/19/2015 23:05:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContentRating]') AND type in (N'U'))
BEGIN
CREATE TABLE [ContentRating](
	[ContentRatingKey] [int] IDENTITY(1,1) NOT NULL,
	[ContentRatingContentKey] [int] NOT NULL,
	[ContentRatingValue] [int] NOT NULL,
	[ContentRatingDate] [datetime] NOT NULL,
	[ContentRatingProviderUserKey] [int] NULL,
	[ContentRatingProviderName] [varchar](150) NULL,
	[ContentRatingProviderEmail] [varchar](150) NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_ContentRating] PRIMARY KEY CLUSTERED 
(
	[ContentRatingKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentRating', N'COLUMN',N'ContentRatingValue'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Number in a scale of 1 to 5.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentRating', @level2type=N'COLUMN',@level2name=N'ContentRatingValue'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentRating', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentRating', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentRating', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentRating', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentRating', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentRating', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentRating', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentRating', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentRating', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentRating', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [Sys_RoleActivity]    Script Date: 06/19/2015 23:05:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_RoleActivity]') AND type in (N'U'))
BEGIN
CREATE TABLE [Sys_RoleActivity](
	[RolerKey] [int] NOT NULL,
	[RoleActivityKey] [int] NOT NULL,
	[RoleCode] [varchar](20) NOT NULL,
	[RoleName] [varchar](50) NOT NULL,
	[ActivityCode] [varchar](20) NOT NULL,
	[ActivityName] [varchar](50) NOT NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_Sys_RoleActivity] PRIMARY KEY CLUSTERED 
(
	[RolerKey] ASC,
	[RoleActivityKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_RoleActivity', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_RoleActivity', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_RoleActivity', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_RoleActivity', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_RoleActivity', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_RoleActivity', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_RoleActivity', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_RoleActivity', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'Sys_RoleActivity', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_RoleActivity', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [Feedback]    Script Date: 06/19/2015 23:05:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Feedback]') AND type in (N'U'))
BEGIN
CREATE TABLE [Feedback](
	[FeedbackKey] [int] IDENTITY(1,1) NOT NULL,
	[FeedbackUserKey] [int] NOT NULL,
	[FeedbackText] [varchar](max) NOT NULL,
	[FeedbackDate] [datetime] NOT NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_Feedback] PRIMARY KEY CLUSTERED 
(
	[FeedbackKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [Feedback] SET (LOCK_ESCALATION = AUTO)
GO
/****** Object:  Table [ContentFeedback]    Script Date: 06/19/2015 23:05:26 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContentFeedback]') AND type in (N'U'))
BEGIN
CREATE TABLE [ContentFeedback](
	[ContentFeedbackKey] [int] IDENTITY(1,1) NOT NULL,
	[ContentFeedbackContentKey] [int] NOT NULL,
	[ContentFeedbackFeedbackKey] [int] NULL,
	[ContentFeedbackText] [varchar](max) NOT NULL,
	[ContentFeedbackDate] [datetime] NOT NULL,
	[ContentFeedbackAuthorUserKey] [int] NULL,
	[ContentFeedbackAuthorName] [varchar](150) NOT NULL,
	[ContentFeedbackAuthorEmail] [varchar](150) NOT NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_ContentFeedback] PRIMARY KEY CLUSTERED 
(
	[ContentFeedbackKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentFeedback', N'COLUMN',N'ContentFeedbackContentKey'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Foreign Key to main content.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentFeedback', @level2type=N'COLUMN',@level2name=N'ContentFeedbackContentKey'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentFeedback', N'COLUMN',N'ContentFeedbackFeedbackKey'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Generally will be Null, Will contain Feedback keyonly if the feedback is against another feedback' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentFeedback', @level2type=N'COLUMN',@level2name=N'ContentFeedbackFeedbackKey'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentFeedback', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentFeedback', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentFeedback', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentFeedback', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentFeedback', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentFeedback', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentFeedback', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentFeedback', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentFeedback', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentFeedback', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [ContentBinaryDataContent]    Script Date: 06/19/2015 23:05:26 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContentBinaryDataContent]') AND type in (N'U'))
BEGIN
CREATE TABLE [ContentBinaryDataContent](
	[ContentMetaDataKey] [int] NOT NULL,
	[ContentBinaryData] [varbinary](max) NULL,
	[ContentThumbnailImage] [varbinary](max) NULL,
	[ContentBinaryDataFileName] [varchar](1000) NULL,
	[ContentBinaryDataType] [varchar](1000) NULL,
	[ContentTotalDownloads] [int] NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_ContentBinaryDataContent_1] PRIMARY KEY CLUSTERED 
(
	[ContentMetaDataKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentBinaryDataContent', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentBinaryDataContent', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentBinaryDataContent', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentBinaryDataContent', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentBinaryDataContent', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentBinaryDataContent', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentBinaryDataContent', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentBinaryDataContent', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'DasIdeenDBAdmin', N'TABLE',N'ContentBinaryDataContent', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'DasIdeenDBAdmin', @level1type=N'TABLE',@level1name=N'ContentBinaryDataContent', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  ForeignKey [FK_ContentBinaryDataContent_ContentMetaDataMaster]    Script Date: 06/19/2015 23:05:26 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentBinaryDataContent_ContentMetaDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentBinaryDataContent]'))
ALTER TABLE [ContentBinaryDataContent]  WITH CHECK ADD  CONSTRAINT [FK_ContentBinaryDataContent_ContentMetaDataMaster] FOREIGN KEY([ContentMetaDataKey])
REFERENCES [ContentMetaDataMaster] ([ContentKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentBinaryDataContent_ContentMetaDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentBinaryDataContent]'))
ALTER TABLE [ContentBinaryDataContent] CHECK CONSTRAINT [FK_ContentBinaryDataContent_ContentMetaDataMaster]
GO
/****** Object:  ForeignKey [FK_ContentFeedback_ContentMetaDataMaster]    Script Date: 06/19/2015 23:05:26 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentFeedback_ContentMetaDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentFeedback]'))
ALTER TABLE [ContentFeedback]  WITH CHECK ADD  CONSTRAINT [FK_ContentFeedback_ContentMetaDataMaster] FOREIGN KEY([ContentFeedbackContentKey])
REFERENCES [ContentMetaDataMaster] ([ContentKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentFeedback_ContentMetaDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentFeedback]'))
ALTER TABLE [ContentFeedback] CHECK CONSTRAINT [FK_ContentFeedback_ContentMetaDataMaster]
GO
/****** Object:  ForeignKey [FK_ContentFeedback_User]    Script Date: 06/19/2015 23:05:26 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentFeedback_User]') AND parent_object_id = OBJECT_ID(N'[ContentFeedback]'))
ALTER TABLE [ContentFeedback]  WITH CHECK ADD  CONSTRAINT [FK_ContentFeedback_User] FOREIGN KEY([ContentFeedbackAuthorUserKey])
REFERENCES [User] ([UserKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentFeedback_User]') AND parent_object_id = OBJECT_ID(N'[ContentFeedback]'))
ALTER TABLE [ContentFeedback] CHECK CONSTRAINT [FK_ContentFeedback_User]
GO
/****** Object:  ForeignKey [FK_ContentMetaDataMaster_ContentTypeMaster]    Script Date: 06/19/2015 23:05:26 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentMetaDataMaster_ContentTypeMaster]') AND parent_object_id = OBJECT_ID(N'[ContentMetaDataMaster]'))
ALTER TABLE [ContentMetaDataMaster]  WITH CHECK ADD  CONSTRAINT [FK_ContentMetaDataMaster_ContentTypeMaster] FOREIGN KEY([ContentTypeKey])
REFERENCES [ContentTypeMaster] ([ContentTypeKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentMetaDataMaster_ContentTypeMaster]') AND parent_object_id = OBJECT_ID(N'[ContentMetaDataMaster]'))
ALTER TABLE [ContentMetaDataMaster] CHECK CONSTRAINT [FK_ContentMetaDataMaster_ContentTypeMaster]
GO
/****** Object:  ForeignKey [FK_ContentRating_ContentMetaDataMaster]    Script Date: 06/19/2015 23:05:27 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentRating_ContentMetaDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentRating]'))
ALTER TABLE [ContentRating]  WITH CHECK ADD  CONSTRAINT [FK_ContentRating_ContentMetaDataMaster] FOREIGN KEY([ContentRatingContentKey])
REFERENCES [ContentMetaDataMaster] ([ContentKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentRating_ContentMetaDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentRating]'))
ALTER TABLE [ContentRating] CHECK CONSTRAINT [FK_ContentRating_ContentMetaDataMaster]
GO
/****** Object:  ForeignKey [FK_ContentRating_User]    Script Date: 06/19/2015 23:05:27 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentRating_User]') AND parent_object_id = OBJECT_ID(N'[ContentRating]'))
ALTER TABLE [ContentRating]  WITH CHECK ADD  CONSTRAINT [FK_ContentRating_User] FOREIGN KEY([ContentRatingProviderUserKey])
REFERENCES [User] ([UserKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentRating_User]') AND parent_object_id = OBJECT_ID(N'[ContentRating]'))
ALTER TABLE [ContentRating] CHECK CONSTRAINT [FK_ContentRating_User]
GO
/****** Object:  ForeignKey [FK__Feedback__Feedba__370627FE]    Script Date: 06/19/2015 23:05:27 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK__Feedback__Feedba__370627FE]') AND parent_object_id = OBJECT_ID(N'[Feedback]'))
ALTER TABLE [Feedback]  WITH CHECK ADD  CONSTRAINT [FK__Feedback__Feedba__370627FE] FOREIGN KEY([FeedbackUserKey])
REFERENCES [FeedbackUser] ([FeedbackUserKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK__Feedback__Feedba__370627FE]') AND parent_object_id = OBJECT_ID(N'[Feedback]'))
ALTER TABLE [Feedback] CHECK CONSTRAINT [FK__Feedback__Feedba__370627FE]
GO
/****** Object:  ForeignKey [FK_FeedbackUser_User]    Script Date: 06/19/2015 23:05:27 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_FeedbackUser_User]') AND parent_object_id = OBJECT_ID(N'[FeedbackUser]'))
ALTER TABLE [FeedbackUser]  WITH CHECK ADD  CONSTRAINT [FK_FeedbackUser_User] FOREIGN KEY([RegisteredUserKey])
REFERENCES [User] ([UserKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_FeedbackUser_User]') AND parent_object_id = OBJECT_ID(N'[FeedbackUser]'))
ALTER TABLE [FeedbackUser] CHECK CONSTRAINT [FK_FeedbackUser_User]
GO
/****** Object:  ForeignKey [FK_Sys_ActivityMaster_Sys_ActivityTypeMaster]    Script Date: 06/19/2015 23:05:27 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_ActivityMaster_Sys_ActivityTypeMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_ActivityMaster]'))
ALTER TABLE [Sys_ActivityMaster]  WITH CHECK ADD  CONSTRAINT [FK_Sys_ActivityMaster_Sys_ActivityTypeMaster] FOREIGN KEY([ActivityTypeKey])
REFERENCES [Sys_ActivityTypeMaster] ([ActivityTypeKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_ActivityMaster_Sys_ActivityTypeMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_ActivityMaster]'))
ALTER TABLE [Sys_ActivityMaster] CHECK CONSTRAINT [FK_Sys_ActivityMaster_Sys_ActivityTypeMaster]
GO
/****** Object:  ForeignKey [FK_Sys_RoleActivity_Sys_ActivityMaster]    Script Date: 06/19/2015 23:05:27 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_RoleActivity_Sys_ActivityMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_RoleActivity]'))
ALTER TABLE [Sys_RoleActivity]  WITH CHECK ADD  CONSTRAINT [FK_Sys_RoleActivity_Sys_ActivityMaster] FOREIGN KEY([RoleActivityKey])
REFERENCES [Sys_ActivityMaster] ([ActivityKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_RoleActivity_Sys_ActivityMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_RoleActivity]'))
ALTER TABLE [Sys_RoleActivity] CHECK CONSTRAINT [FK_Sys_RoleActivity_Sys_ActivityMaster]
GO
/****** Object:  ForeignKey [FK_Sys_RoleActivity_Sys_RoleMaster]    Script Date: 06/19/2015 23:05:27 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_RoleActivity_Sys_RoleMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_RoleActivity]'))
ALTER TABLE [Sys_RoleActivity]  WITH CHECK ADD  CONSTRAINT [FK_Sys_RoleActivity_Sys_RoleMaster] FOREIGN KEY([RolerKey])
REFERENCES [Sys_RoleMaster] ([RoleKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_RoleActivity_Sys_RoleMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_RoleActivity]'))
ALTER TABLE [Sys_RoleActivity] CHECK CONSTRAINT [FK_Sys_RoleActivity_Sys_RoleMaster]
GO
/****** Object:  ForeignKey [FK_Sys_TableMaster_Sys_ModuleMaster]    Script Date: 06/19/2015 23:05:27 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_TableMaster_Sys_ModuleMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_TableMaster]'))
ALTER TABLE [Sys_TableMaster]  WITH CHECK ADD  CONSTRAINT [FK_Sys_TableMaster_Sys_ModuleMaster] FOREIGN KEY([ModuleID])
REFERENCES [Sys_ModuleMaster] ([ModuleID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_TableMaster_Sys_ModuleMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_TableMaster]'))
ALTER TABLE [Sys_TableMaster] CHECK CONSTRAINT [FK_Sys_TableMaster_Sys_ModuleMaster]
GO
/****** Object:  ForeignKey [FK_UserProfile_User]    Script Date: 06/19/2015 23:05:28 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserProfile_User]') AND parent_object_id = OBJECT_ID(N'[UserProfile]'))
ALTER TABLE [UserProfile]  WITH CHECK ADD  CONSTRAINT [FK_UserProfile_User] FOREIGN KEY([UserKey])
REFERENCES [User] ([UserKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserProfile_User]') AND parent_object_id = OBJECT_ID(N'[UserProfile]'))
ALTER TABLE [UserProfile] CHECK CONSTRAINT [FK_UserProfile_User]
GO
/****** Object:  ForeignKey [FK_UserProfileImage_User]    Script Date: 06/19/2015 23:05:28 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserProfileImage_User]') AND parent_object_id = OBJECT_ID(N'[UserProfileImage]'))
ALTER TABLE [UserProfileImage]  WITH CHECK ADD  CONSTRAINT [FK_UserProfileImage_User] FOREIGN KEY([UserKey])
REFERENCES [User] ([UserKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserProfileImage_User]') AND parent_object_id = OBJECT_ID(N'[UserProfileImage]'))
ALTER TABLE [UserProfileImage] CHECK CONSTRAINT [FK_UserProfileImage_User]
GO
/****** Object:  ForeignKey [FK_UserRole_Sys_RoleMaster]    Script Date: 06/19/2015 23:05:28 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserRole_Sys_RoleMaster]') AND parent_object_id = OBJECT_ID(N'[UserRole]'))
ALTER TABLE [UserRole]  WITH CHECK ADD  CONSTRAINT [FK_UserRole_Sys_RoleMaster] FOREIGN KEY([UserRoleKey])
REFERENCES [Sys_RoleMaster] ([RoleKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserRole_Sys_RoleMaster]') AND parent_object_id = OBJECT_ID(N'[UserRole]'))
ALTER TABLE [UserRole] CHECK CONSTRAINT [FK_UserRole_Sys_RoleMaster]
GO
/****** Object:  ForeignKey [FK_UserRole_User]    Script Date: 06/19/2015 23:05:28 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserRole_User]') AND parent_object_id = OBJECT_ID(N'[UserRole]'))
ALTER TABLE [UserRole]  WITH CHECK ADD  CONSTRAINT [FK_UserRole_User] FOREIGN KEY([UserKey])
REFERENCES [User] ([UserKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserRole_User]') AND parent_object_id = OBJECT_ID(N'[UserRole]'))
ALTER TABLE [UserRole] CHECK CONSTRAINT [FK_UserRole_User]
GO
